package com.itheima.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class R {
    private Integer code;
    private Object data;
    private String msg;
    // 增删改
    public static R success(String msg){
        R r = new R();
        r.setCode(1);
        r.setMsg(msg);
        return r;
    }
    // 查询成功
    public static R success(Object data){
        R r = new R();
        r.setCode(1);
        r.setData(data);
        r.setMsg("成功");
        return r;
    }
    // 失败
    public static R error(String msg){
        R r = new R();
        r.setCode(1);
        r.setMsg(msg);
        return r;
    }
}